<extend name="Public/base"/>
<block name="content">
<h3 class="col-md-8">Ftp管理</h3>
<form id="import-form" class="form-horizontal"  method="post" action="<{:addons_url('Ftp://Ftp/storage')}>">
<div class="row">	
	<div class="col-lg-12">
		<div class="panel panel-default">
	        <div class="panel-heading">
	            设置参数
	            <a class="pull-right" title="" data-toggle="tooltip" data-perform="panel-collapse" href="javascript:void(0);" data-original-title="显示/隐藏">
				<em class="fa fa-minus"></em>
				</a>
	        </div>
	     	<div class="panel-body">     		
	     		<div class="col-lg-4">      
		    		<div class="form-group">	
		    			<label class="col-sm-3 control-label">所属艺术家</label>
		    			<div class="col-sm-9">
		    				<div class="input-group">
		    					<input type="text" class="hide" id="artist-id" name="artist_id" value="0">	
		    					<input type="text" class="form-control" id="artist-name" name="artist_name"  value="<{$data.artist_name|default='佚名'}>">	
								<a href="#" class="input-group-addon ajax-find" rel="artist">
		                         	<span class="fa-search fa"></span>
		                    	</a>
		                    </div>
		    			</div>	
		            </div>
					<div class="form-group">	
						<label class="col-sm-3 control-label">所属曲风</label>
						<div class="col-sm-9">
							<select name="genre_id" class="form-control">
			        		<volist name=":get_genre_tree()" id="genre">	        			
			            		<option value="<{$genre.id}>"><{$genre.title_show}></option>
			        		</volist>
							</select>
						</div>	
					</div> 
					
					<div class="form-group">	
		    			<label class="col-sm-3 control-label">所属专辑</label>
		    			<div class="col-sm-9">
		   					<div class="input-group">
		    					<input type="text"  class="hide" name="album_id" id="album-id" value="0">
		    					<input type="text" class="form-control"  name="album_name" id="album-name" value="单曲">
								<a href="#" class="input-group-addon ajax-find" rel="album">
		                         	<span class="fa-search fa"></span>
		                    	</a>
		                    </div>
		    			</div>	
		    		</div>
		    		
		    		<div class="form-group">		
		    			<label class="col-sm-3 control-label">所属用户</label>
		    			<div class="col-sm-3 controls">	
		    				<input type="text" class="form-control"  name="up_uid"  value="">	                   
		    			</div>	
		    			<p class="help-block col-sm-6">填写会员ID</p>	
		    	    </div>	
					     
	         	</div>
	         	
	         	<div class="col-lg-4">
	              	<div class="form-group">						
		    			<label class="col-sm-3 control-label ">试听次数</label>
		    			<div class="col-sm-4 controls">
		    				<input type="text" class="form-control"  value="200-1000" name="listens">
		    			</div>
		    			<span class="help-block">整数/随机数：格式 1-200</span>
		    		</div>
		    		
		    		<div class="form-group">						
		    			<label class="col-sm-3 control-label ">下载次数</label>
		    			<div class="col-sm-4 controls">
		    				<input type="text" class="form-control"  value="200-1000" name="download">
		    			</div>
		    			<span class="help-block">整数/随机数：格式 1-200</span>
		    		</div>
		    		
		    		<div class="form-group">						
		    			<label class="col-sm-3 control-label ">下载积分</label>
		    			<div class="col-sm-4 controls">
		    				<input type="text" class="form-control"  value="0" name="gold">
		    			</div>
		    		</div>
		    		
		    		<div class="form-group">						
		    			<label class="col-sm-3 control-label ">评分</label>
		    			<div class="col-sm-4 controls">
		    				<input type="text" class="form-control"  value="6" name="rater">
		    			</div>
		    			<span class="help-block"></span>
		    		</div>
	   			</div>	   			   		
	   			<div class="col-lg-4">
	   				<div class="form-group">						
		    			<label class="col-sm-3 control-label ">下载目录</label>
		    			<div class="col-sm-4 controls">
		    				<input type="text" class="form-control"  value="" name="down_dir">
		    			</div>
		    			<span class="help-block">格式Music/listen/ 留空和试听地址相同</span>
		    		</div>
		    		
		    		<div class="form-group">						
		    			<label class="col-sm-3 control-label ">下载音质</label>
		    			<div class="col-sm-4 controls">
		    				<input type="text" class="form-control"  value="320k" name="down_bit">
		    			</div>
		    			<span class="help-block"></span>
		    		</div>
	   				
	   				<div class="form-group">		
						<label class="col-sm-3 control-label">推荐</label>
		    			<div class="col-sm-9 controls">
							<input class="hide" name="recommend" value="0">
							<div  class="switch-wrapper">
								<span class="switch-enable">是</span>
								<span class="switch-disable selected">否</span>	
							</div>
		                </div>	
		    	    </div>		    	    
					     
	         	</div>
	   		
	   		</div>  
	   </div>	   
	</div>
</div>
<div class="row">
    <div class="col-lg-12">
    	<div class="panel panel-default">
       		<div class="panel-heading ">文件列表
       			<div class="btn-group pull-right">
	       			<a class="btn btn-labeled btn-success" id="import" href="">入库</a>
	         	</div>      			
       		</div>
    		<div class="table-responsive">
        		<table class="table table-striped table-bordered table-hover">           
            		<thead>
                		<tr>
                			<th style="width: 5%" class="check-all">
                          		<div data-toggle="tooltip"  data-title="全选" class="checkbox c-checkbox">
                             		<label>
                                		<input type="checkbox" checked="chedked">
                                		<span class="fa fa-check"></span>
                             		</label>
                          		</div>
                       		</th> 
                            <th>ID</th>
            				<th>文件名称</th>
            				<th>状态</th>
                         	<!--th class="text-center">操作</th-->
                    	</tr>
                	</thead>
                    <tbody>
                    	<notempty name="list">
                    	<volist name="list" id='vo'>
                      	<tr>
                        	<td>
                          		<div class="checkbox c-checkbox">
                             		<label>
                                	<input type="checkbox" class="ids" checked="chedked" value="<{$vo['id']}>" name="tables[]">
                                	<span class="fa fa-check"></span>
                             		</label>
                          		</div>
                       		</td>				
        					<td><{$i}></td>
        					<td class='m-name'><{$vo['name']}></td>
        					<td class="info">未导入</td>
                    		<!--td class="text-center">
	                            <a class="btn btn-labeled btn-sm " href="javascript:void(0);">入库</a>
                         	</td-->
                      	</tr>
                      	</volist>
        				<else/>
        				<td colspan="10" class="text-center">暂时还没有内容! </td>
        				</notempty>
                    </tbody>
                </table>
    		</div>
    		<!-- 结束 表格 -->
    		<div class="panel-footer">
				<div class="row">
					<div class="page">
					
					</div>
				</div>
            </div>    		
    	</div>
	</div>
</div>

</form>
</block>
<block name="script">
<script type="text/javascript"  src="__JS__/other.js"></script>
<script type="text/javascript">
	//导航高亮
	highlight_subnav("<{:U('Addons/adminList/name/Ftp')}>");
	var findUrl="<{:U('Ajax/findData')}>";
    (function($){
        var $form = $("#import-form"), $export = $("#import"), tables;
        $export.click(function(){
            $export.parent().children().addClass("disabled");
            $export.html("正在发送入库请求...");
            $.post(
                $form.attr("action"),
                $form.serialize(),
                function(data){
                    if(data.status){
                        tables = data.tables;
                        $export.html(data.info + "开始导入，请不要关闭本页面！");
                        backup(data.tab);
                        window.onbeforeunload = function(){ return "正在导入数据，请不要关闭！" }
                    } else {
                        topAlert(data.info,'alert-error');
                        $export.parent().children().removeClass("disabled");
                        $export.html("开始导入");
                    }
                },
                "json"
            );
            return false;
        });

        function backup(tab, status){
        	//alert(tab);
            status && showmsg(tab.id, "开始导入...");
            $.get($form.attr("action"), tab, function(data){
                if(data.status){
                    showmsg(tab.id, data.info);
                    if(!$.isPlainObject(data.tab)){
                        $export.parent().children().removeClass("disabled");                        
                        $export.html("导入完成").focus();
                        window.onbeforeunload = function(){ return null }
                        if(data.url){location.reload();}
                        return;
                    }                  
                    backup(data.tab, tab.id != data.tab.id);
                } else {
                    topAlert(data.info,'alert-error');
                    $export.parent().children().removeClass("disabled");
                    $export.html("立即导入");
                }
            }, "json");
        }

        function showmsg(id, msg){
            $form.find("input[value=" + tables[id] + "]").closest("tr").find(".info").html(msg);
        }
        
        
        
    })(jQuery);


</script>
</block>	


